<!--
 * @Author: 杨光辉_GerhardYang
 * @Date: 2021-03-01 10:35:28
 * @LastEditors: 杨光辉(GerhardYang)
 * @LastEditTime: 2021-06-06 19:07:21
 * @Description: file content
-->
<template>
  <a-row class="navbtns">
    <a-col :span="8">
      <a-button type="link" title="距离测量" @click="disM">
        <icon-font type="icon-juliceliang" />
      </a-button>
    </a-col>
    <a-col :span="8">
      <a-button type="link" title="面积测量" @click="disA">
        <icon-font type="icon-mianji" />
      </a-button>
    </a-col>
    <a-col :span="8">
      <a-button type="link" title="清除" @click="clear">
        <icon-font type="icon-shanchu11" />
      </a-button>
    </a-col>
  </a-row>
</template>

<script>
import { Icon } from "ant-design-vue";
const IconFont = Icon.createFromIconfontCN({
  scriptUrl: "./iconfont/iconfont.js",
});

export default {
  components: {
    IconFont,
  },
  computed: {
    map() {
      return this.$store.state.map;
    },
  },
  methods: {
    disM: function () {
      this.map._distControl.addHooks();
    },
    disA: function () {
      this.map._areaControl._onMouseClick();
    },
    clear() {
      //清除测量
      let map = this.map;
      if (map._distControl._currentDist) {
        for (let i = 0; i < map._distControl._currentDist._layers.length; i++) {
          map.removeLayer(map._distControl._currentDist._layers[i]);
        }
      }
      if (map._areaControl._compute) {
        for (let i = 0; i < map._areaControl._compute._layers.length; i++) {
          map.removeLayer(map._areaControl._compute._layers[i]);
        }
      }
    },
  },
};
</script>

<style lang="less" scoped>
.navbtns {
  height: 40px;
  text-align: center;
  i {
    line-height: 40px !important;
    font-size: 22px !important;
  }
}
</style>
